package com.linewow.xhyy.nihaonew.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.linewow.xhyy.nihaonew.R;
import com.linewow.xhyy.nihaonew.entity.user.SimpleUserInfo;
import com.linewow.xhyy.nihaonew.model.HttpModel;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by LXR on 2016/10/12.
 */
public class ShieldAdapter extends BaseQuickAdapter<SimpleUserInfo> {
    private Context context;
    private String TAG = "FanAdapter";

    public ShieldAdapter(List<SimpleUserInfo> data) {
        super(R.layout.item_shield,data);
    }
    @Override
    protected void convert(BaseViewHolder baseViewHolder, SimpleUserInfo simpleUserInfo) {
        if(context==null){
            context=baseViewHolder.getConvertView().getContext();
        }
        if (simpleUserInfo.gender.equals("0")) {
            baseViewHolder.setVisible(R.id.item_shield_gender,false);
        } else if (simpleUserInfo.gender.equals("1")) {
            baseViewHolder.setVisible(R.id.item_shield_gender,true);
            baseViewHolder.setImageResource(R.id.item_shield_gender,R.mipmap.icon_gender_male);
        } else {
            baseViewHolder.setVisible(R.id.item_shield_gender,true);
            baseViewHolder.setImageResource(R.id.item_shield_gender,R.mipmap.icon_gender_female);
        }
        baseViewHolder.setText(R.id.item_shield_nick,simpleUserInfo.nickname);
        baseViewHolder.addOnClickListener(R.id.item_shield_follow_content);
        ImageView imageView=baseViewHolder.getView(R.id.item_shield_avatar);
        Picasso.with(context).load((HttpModel.HOMEURL+simpleUserInfo.avatar).replace("m.en1on1.com", "huibenabc.com")).error(R.mipmap.err_avatar).placeholder(R.mipmap.err_avatar).fit().into(imageView);
        baseViewHolder.setText(R.id.item_shield_location,simpleUserInfo.area);
    }

}
